package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.common.util.AjaxResult;
import cn.wolfcode.luowowo.website.util.UploadUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadController {

    @Value("${file.path}")
    private String filePath;

    //上传图片
    @RequestMapping("/coverImageUpload")
    @ResponseBody
    public Object coverImageUpload(MultipartFile pic){
        String upload = UploadUtil.upload(pic, filePath);
        return upload;
    }
    //上传头像
    @RequestMapping("/upload/file")
    @ResponseBody
    public Object file(MultipartFile files){
        String upload = UploadUtil.uploadHeadImg(files,filePath);
        AjaxResult result = new AjaxResult();
        result.setData(upload);
        return result;
    }
}